<?php
require_once('Extension/Controller/Action.php');

class Admin_CacheController extends Extension_Controller_Action 
{
    public function indexAction()
    {
        echo 'none action specific !';
        exit();
    }

    public function clearAction() 
    {
        $cache = Kbs::initCache('FormLucene');

        if (false != $cache) {

            if ($this->getRequest()->isGet()) {
                $tags = $this->_getParam('tags');
                if ($tags) {
                    $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, explode(',', $tags));
                    $this->view->clearMessage = 'clear forms !';
                }
            } else {

                $clearAll = $this->_getParam('all');
                
                if ($clearAll) {
                    $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
                    $this->view->clearMessage = 'clear all !';
                } else {
                    $cache->clean(Zend_Cache::CLEANING_MODE_OLD);
                    $this->view->clearMessage = 'clear expired !';
                }
            }
        } else {
            $this->view->clearMessage = 'no cache available !';
        }

    }

}